package com.example.isoftservice.controller;


import com.example.isoftservice.util.Result;
import com.example.isoftservice.pojos.Stock;
import com.example.isoftservice.service.StockService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@CrossOrigin
@RestController
public class StockController {
    @Resource
    private StockService stockService;

    @RequestMapping(value = "/stock/sumbitselect", method = RequestMethod.GET)

    public Result<Map<String, Object>> sumbitselect(Stock stock) {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("查询成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(stockService.selectSubmit(stock));


        return result;

    }


    @RequestMapping(value = "/stock/passselect", method = RequestMethod.GET)

    public Result<Map<String, Object>> passselect(Stock stock) {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("查询成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(stockService.selectPass(stock));


        return result;

    }

    @RequestMapping(value = "/stock/nopassselect", method = RequestMethod.GET)

    public Result<Map<String, Object>> nopassselect(Stock stock) {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("查询成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(stockService.selectNoPass(stock));


        return result;

    }

    @RequestMapping(value = "/stock/address", method = RequestMethod.GET)

    public Result<Map<String, Object>> address() {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("查询成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(stockService.selectAdress());


        return result;

    }

    @RequestMapping(value = "/stock/dealer", method = RequestMethod.GET)

    public Result<Map<String, Object>> dealer() {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("查询成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(stockService.selectDealer());


        return result;

    }

    @RequestMapping(value = "/stock/product", method = RequestMethod.GET)

    public Result<Map<String, Object>> product() {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("查询成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(stockService.selectProduct());


        return result;

    }

    @RequestMapping(value = "/stock/insert", method = RequestMethod.POST)

    public Result<Map<String, Object>> insert(@RequestBody Stock stock) {
        System.out.println("eaaaaaaaaaaaaaaaaaaaaa" + stock);
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(stockService.stockInsert(stock));


        return result;

    }

    @RequestMapping(value = "/stock/delete", method = RequestMethod.POST)

    public Result<Map<String, Object>> Delete(@RequestBody Stock stock) {
      
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(stockService.stockDelete(stock));


        return result;

    }

    @RequestMapping(value = "/stock/update", method = RequestMethod.GET)
    public Result<Map<String, Object>> modifyStockInfo(Stock stock) {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(stockService.stockUpdate(stock));
        return result;


    }
    @RequestMapping(value = "/selectstatus", method = RequestMethod.GET)

    public Map<String, Object> selectStatus(Stock stock) {

        return this.stockService.selectStatus(stock);

    }
}
